﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Windows.Forms;
namespace Group16.Class_Library
{
    public class InvoiceDetails
    {
        private string _invoiceCode;
        private string _customer;
        private List<string> _deviceCodes = new List<string>();
        public string InvoiceCode
        {
            get { return _invoiceCode; }
            set { _invoiceCode = value; }
        }
        public string CustomerCode
        {
            get { return _customer; }
            set { _customer = value; }
        }
        public List<string> DevicesCodes
        {
            get { return _deviceCodes; }
        }
        public void LogData()
        {
            try
            {
                foreach (string s in DevicesCodes)
                {
                    string comText = "Insert Into InvoiceDetails Values('" + InvoiceCode + "','" + CustomerCode + "','" + s + "')";
                    DataBaseInteraction.ExecuteCommand(comText, 1);
                }
            }
            catch (SqlException se)
            {
                MessageBox.Show("Unable to insert " + se.Message);

            }
            finally
            {
                DataBaseInteraction.Connection.Close();
            }
        }

    }
}
